<template>
    <div class="page-container">
        <Header></Header>
        <div class="main-container">
            <div class="content-grid">
                <!-- 左边栏 -->
                <div class="main-content">
                    <div class="category-header">
                        {{ categoryName }}
                    </div>
                    <ArticleList :categoryId="route.params.categoryId"></ArticleList>
                </div>
                <!-- 右边栏 -->
                <aside class="sidebar-container">
                    <TagCard />
                </aside>
            </div>
        </div>
        <Footer />
    </div>
</template>

<script setup>
import Header from '@/layouts/components/Header.vue'
import Footer from '@/layouts/components/Footer.vue'
import { useRouter, useRoute } from 'vue-router'
import { ref } from 'vue'
import ArticleList from '@/components/ArticleList.vue'
import TagCard from '@/components/TagCard.vue'

const router = useRouter()
const route = useRoute()
const categoryName = ref(route.params.name)
</script>

<style scoped>
.page-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-container {
    flex: 1;
    max-width: 1230px;
    width: 100%;
    margin: 0 auto;
    margin-top: 20px;
    padding: 0 15px;
    box-sizing: border-box;
}

.content-grid {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
}

.main-content {
    width: 100%;
    box-sizing: border-box;
}

.sidebar-container {
    width: 100%;
    box-sizing: border-box;
}

.category-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    font-size: 20px;
    font-weight: 600;
    color: #4b5563;
}

/* 深色模式 */
@media (prefers-color-scheme: dark) {
    .category-header {
        color: #f9fafb;
    }
}

/* 响应式布局 */
@media (max-width: 768px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}
</style>